
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>logback中文网|第五章：Encoder</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="logback中文网包含了logback中文文档，最新资讯，应用案例等。logback 继承自 log4j，它建立在有十年工业经验的日志系统之上。它比其它所有的日志系统更快并且更小，包含了许多独特并且有用的特性。"><meta name="keywords" content="logback中文文档, logback api文档, logback log4j,springboot logback,logback日志类型">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="06第六章Layouts.html" />
    
    
    <link rel="prev" href="04第四章Appenders.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="01第一章logback介绍.html">
            
                <a href="01第一章logback介绍.html">
            
                    
                    第一章：logback 介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="02第二章架构.html">
            
                <a href="02第二章架构.html">
            
                    
                    第二章：架构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="03第三章logback的配置.html">
            
                <a href="03第三章logback的配置.html">
            
                    
                    第三章：logback 的配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="04第四章Appenders.html">
            
                <a href="04第四章Appenders.html">
            
                    
                    第四章：Appenders
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6" data-path="05第五章Encoder.html">
            
                <a href="05第五章Encoder.html">
            
                    
                    第五章：Encoder
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="06第六章Layouts.html">
            
                <a href="06第六章Layouts.html">
            
                    
                    第六章：Layouts
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="07第七章Filters.html">
            
                <a href="07第七章Filters.html">
            
                    
                    第七章：Filters
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="08第八章MDC.html">
            
                <a href="08第八章MDC.html">
            
                    
                    第八章：MDC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="09第九章日志隔离.html">
            
                <a href="09第九章日志隔离.html">
            
                    
                    第九章：日志隔离
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="10第十章JMX配置器.html">
            
                <a href="10第十章JMX配置器.html">
            
                    
                    第十章：JMX 配置器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="11第十一章Joran.html">
            
                <a href="11第十一章Joran.html">
            
                    
                    第十一章：Joran
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="12第十二章Groovy配置.html">
            
                <a href="12第十二章Groovy配置.html">
            
                    
                    第十二章：Groovy 配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="13第十三章从log4j迁移.html">
            
                <a href="13第十三章从log4j迁移.html">
            
                    
                    第十三章：从 log4j 迁移
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="14第十四章Receivers.html">
            
                <a href="14第十四章Receivers.html">
            
                    
                    第十四章：Receivers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="15第十五章使用SSL.html">
            
                <a href="15第十五章使用SSL.html">
            
                    
                    第十五章：使用 SSL
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >第五章：Encoder</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x4EC0;&#x4E48;&#x662F;-encoder">&#x4EC0;&#x4E48;&#x662F; encoder</h2>
<p>encoder &#x5C06;&#x65E5;&#x5FD7;&#x4E8B;&#x4EF6;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x8282;&#x6570;&#x7EC4;&#xFF0C;&#x540C;&#x65F6;&#x5C06;&#x5B57;&#x8282;&#x6570;&#x7EC4;&#x5199;&#x5165;&#x5230;&#x4E00;&#x4E2A; <code>OutputStream</code> &#x4E2D;&#x3002;encoder &#x5728; logback 0.9.19 &#x7248;&#x672C;&#x5F15;&#x8FDB;&#x3002;&#x5728;&#x4E4B;&#x524D;&#x7684;&#x7248;&#x672C;&#x4E2D;&#xFF0C;&#x5927;&#x591A;&#x6570;&#x7684; appender &#x4F9D;&#x8D56; layout &#x5C06;&#x65E5;&#x5FD7;&#x4E8B;&#x4EF6;&#x8F6C;&#x6362;&#x4E3A; string&#xFF0C;&#x7136;&#x540E;&#x518D;&#x901A;&#x8FC7; <code>java.io.Writer</code> &#x5199;&#x51FA;&#x3002;&#x5728;&#x4E4B;&#x524D;&#x7684;&#x7248;&#x672C;&#x4E2D;&#xFF0C;&#x7528;&#x6237;&#x9700;&#x8981;&#x5728; <code>FileAppender</code> &#x4E2D;&#x5185;&#x7F6E;&#x4E00;&#x4E2A; <code>PatternLayout</code>&#x3002;&#x5728; 0.9.19 &#x4E4B;&#x540E;&#x7684;&#x7248;&#x672C;&#x4E2D;&#xFF0C;<code>FileAppender</code> &#x4EE5;&#x53CA;&#x5B50;&#x7C7B;<a href="https://logback.qos.ch/codes.html#layoutInsteadOfEncoder" target="_blank">&#x9700;&#x8981;&#x4E00;&#x4E2A; encoder &#x800C;&#x4E0D;&#x662F; layout</a>&#x3002;</p>
<p>&#x4E3A;&#x4EC0;&#x4E48;&#x4F1A;&#x6709;&#x8FD9;&#x4E2A;&#x6539;&#x53D8;&#xFF1F;</p>
<p>layout &#x5C06;&#x4F1A;&#x5728;&#x4E0B;&#x4E00;&#x7AE0;&#x8282;&#x8BA8;&#x8BBA;&#xFF0C;&#x5B83;&#x53EA;&#x80FD;&#x5C06;&#x65E5;&#x5FD7;&#x4E8B;&#x4EF6;&#x8F6C;&#x6362;&#x4E3A;&#x6210; string&#x3002;&#x800C;&#x4E14;&#xFF0C;&#x8003;&#x8651;&#x5230; layout &#x5728;&#x65E5;&#x5FD7;&#x4E8B;&#x4EF6;&#x5199;&#x51FA;&#x65F6;&#x4E0D;&#x80FD;&#x63A7;&#x5236;&#x65E5;&#x5FD7;&#x4E8B;&#x4EF6;&#xFF0C;&#x4E0D;&#x80FD;&#x5C06;&#x65E5;&#x5FD7;&#x4E8B;&#x4EF6;&#x6279;&#x91CF;&#x805A;&#x5408;&#x3002;&#x4E0E;&#x4E4B;&#x76F8;&#x53CD;&#x7684;&#x662F;&#xFF0C;encoder &#x4E0D;&#x4F46;&#x53EF;&#x4EE5;&#x5B8C;&#x5168;&#x63A7;&#x5236;&#x5B57;&#x8282;&#x5199;&#x51FA;&#x65F6;&#x7684;&#x683C;&#x5F0F;&#xFF0C;&#x800C;&#x4E14;&#x8FD8;&#x53EF;&#x4EE5;&#x63A7;&#x5236;&#x8FD9;&#x4E9B;&#x5B57;&#x8282;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x88AB;&#x5199;&#x51FA;&#x3002;</p>
<p><code>PatternLayoutEncoder</code> &#x662F;&#x76EE;&#x524D;&#x771F;&#x6B63;&#x552F;&#x4E00;&#x6709;&#x7528;&#x7684; encoder&#x3002;&#x5B83;&#x4EC5;&#x4EC5;&#x5305;&#x88F9;&#x4E86;&#x4E00;&#x4E2A; <code>PatternLayout</code> &#x5C31;&#x5B8C;&#x6210;&#x4E86;&#x5927;&#x90E8;&#x5206;&#x7684;&#x5DE5;&#x4F5C;&#x3002;&#x56E0;&#x6B64;&#xFF0C;&#x9664;&#x4E86;&#x4E0D;&#x5FC5;&#x8981;&#x7684;&#x590D;&#x6742;&#x6027;&#xFF0C;encoder &#x4F3C;&#x4E4E;&#x4E0D;&#x4F1A;&#x6709;&#x592A;&#x591A;&#x7684;&#x7528;&#x5904;&#x3002;&#x4F46;&#x662F;&#xFF0C;&#x6211;&#x4EEC;&#x5E0C;&#x671B;&#x4E00;&#x4E2A;&#x5168;&#x65B0;&#x7684;&#x66F4;&#x52A0;&#x5F3A;&#x5927;&#x7684; encoder &#x6765;&#x6539;&#x53D8;&#x8FD9;&#x79CD;&#x5370;&#x8C61;&#x3002;</p>
<h2 id="encoder-&#x63A5;&#x53E3;">Encoder &#x63A5;&#x53E3;</h2>
<p>encoder &#x8D1F;&#x8D23;&#x5C06;&#x65E5;&#x5FD7;&#x4E8B;&#x4EF6;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x8282;&#x6570;&#x7EC4;&#xFF0C;&#x5E76;&#x5C06;&#x5B57;&#x8282;&#x6570;&#x7EC4;&#x5199;&#x5165;&#x5230;&#x5408;&#x9002;&#x7684; <code>OutputStream</code> &#x4E2D;&#x3002;&#x6240;&#x4EE5;&#xFF0C;encoder &#x53EF;&#x4EE5;&#x5B8C;&#x5168;&#x63A7;&#x5236;&#x5C06;&#x4EC0;&#x4E48;&#x6837;&#x7684;&#x5B57;&#x8282;&#x4EE5;&#x53CA;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x5C06;&#x5B57;&#x8282;&#x5199;&#x5165;&#x5230;&#x7531; appender &#x7EF4;&#x62A4;&#x7684; <code>OutputStream</code> &#x4E2D;&#x3002;&#x4E0B;&#x9762;&#x662F; <a href="https://logback.qos.ch/xref/ch/qos/logback/core/encoder/Encoder.html" target="_blank">Encoder &#x63A5;&#x53E3;:</a> </p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> ch.qos.logback.core.encoder;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">Encoder</span>&lt;<span class="hljs-title">E</span>&gt; <span class="hljs-keyword">extends</span> <span class="hljs-title">ContextAware</span>, <span class="hljs-title">LifeCycle</span> </span>{

   <span class="hljs-comment">/**
   * This method is called when the owning appender starts or whenever output
   * needs to be directed to a new OutputStream, for instance as a result of a
   * rollover.
   */</span>
  <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">init</span><span class="hljs-params">(OutputStream os)</span> <span class="hljs-keyword">throws</span> IOException</span>;

  <span class="hljs-comment">/**
   * Encode and write an event to the appropriate {<span class="hljs-doctag">@link</span> OutputStream}.
   * Implementations are free to defer writing out of the encoded event and
   * instead write in batches.
   */</span>
  <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">doEncode</span><span class="hljs-params">(E event)</span> <span class="hljs-keyword">throws</span> IOException</span>;


  <span class="hljs-comment">/**
   * This method is called prior to the closing of the underling
   * {<span class="hljs-doctag">@link</span> OutputStream}. Implementations MUST not close the underlying
   * {<span class="hljs-doctag">@link</span> OutputStream} which is the responsibility of the owning appender.
   */</span>
  <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">close</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> IOException</span>;
}
</code></pre>
<p>&#x6B63;&#x5982;&#x4F60;&#x6240;&#x770B;&#x89C1;&#x7684;&#xFF0C;<code>Encoder</code> &#x63A5;&#x53E3;&#x4EC5;&#x4EC5;&#x5305;&#x542B;&#x51E0;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x4F46;&#x662F;&#x4EE4;&#x4EBA;&#x60CA;&#x8BB6;&#x7684;&#x662F;&#x8FD9;&#x4E9B;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x5B8C;&#x6210;&#x8BB8;&#x591A;&#x6709;&#x7528;&#x7684;&#x4E8B;&#x60C5;&#x3002;</p>
<h2 id="layoutwrappingencoder">LayoutWrappingEncoder</h2>
<p>&#x76F4;&#x5230; logback &#x7684; 0.9.19 &#x7248;&#x672C;&#xFF0C;&#x8BB8;&#x591A; appender &#x4F9D;&#x8D56; layout &#x5B9E;&#x4F8B;&#x53BB;&#x63A7;&#x5236;&#x65E5;&#x5FD7;&#x7684;&#x683C;&#x5F0F;&#x5316;&#x8F93;&#x51FA;&#x3002;&#x56E0;&#x4E3A;&#x57FA;&#x4E8E; layout &#x63A5;&#x53E3;&#x5B58;&#x5728;&#x4E86;&#x5927;&#x91CF;&#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x4E00;&#x79CD;&#x65B9;&#x5F0F;&#x5BB9; encoder &#x4E0E; layout &#x8FDB;&#x884C;&#x4EA4;&#x4E92;&#x3002;<a href="https://logback.qos.ch/xref/ch/qos/logback/core/encoder/LayoutWrappingEncoder.html" target="_blank">LayoutWrappingEncoder</a> &#x5C31;&#x662F; encoder &#x4E0E; layout &#x4E4B;&#x95F4;&#x7684;&#x6865;&#x6881;&#x3002;&#x5B83;&#x5B9E;&#x73B0;&#x4E86; encoder &#x63A5;&#x53E3;&#x5E76;&#x4E14;&#x5305;&#x88F9;&#x4E86;&#x4E00;&#x4E2A; layout&#xFF0C;&#x901A;&#x8FC7;&#x59D4;&#x6258;&#x8BE5; layout &#x5C06;&#x65E5;&#x5FD7;&#x4E8B;&#x4EF6;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x662F; <code>LayoutWrappingEncoder</code> &#x7684;&#x90E8;&#x5206;&#x4EE3;&#x7801;&#xFF0C;&#x8BF4;&#x660E;&#x4E86;&#x5982;&#x4F55;&#x59D4;&#x6258;&#x5305;&#x88F9;&#x7684; layout &#x5B9E;&#x4F8B;&#x53BB;&#x5B8C;&#x6210;&#x5DE5;&#x4F5C;&#x3002;</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> ch.qos.logback.core.encoder;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">LayoutWrappingEncoder</span>&lt;<span class="hljs-title">E</span>&gt; <span class="hljs-keyword">extends</span> <span class="hljs-title">EncoderBase</span>&lt;<span class="hljs-title">E</span>&gt; </span>{

  <span class="hljs-keyword">protected</span> Layout&lt;E&gt; layout;
  <span class="hljs-keyword">private</span> Charset charset;

   <span class="hljs-comment">// encode a given event as a byte[]</span>
   <span class="hljs-keyword">public</span> <span class="hljs-keyword">byte</span>[] encode(E event) {
     String txt = layout.doLayout(event);
     <span class="hljs-keyword">return</span> convertToBytes(txt);
  }

  <span class="hljs-keyword">private</span> <span class="hljs-keyword">byte</span>[] convertToBytes(String s) {
    <span class="hljs-keyword">if</span> (charset == <span class="hljs-keyword">null</span>) {
      <span class="hljs-keyword">return</span> s.getBytes();
    } <span class="hljs-keyword">else</span> {
      <span class="hljs-keyword">return</span> s.getBytes(charset);
    }
  } 
}
</code></pre>
<p><code>doLayout()</code> &#x65B9;&#x6CD5;&#x9996;&#x5148;&#x901A;&#x8FC7;&#x5305;&#x88F9;&#x7684; layout &#x5C06;&#x65E5;&#x5FD7;&#x4E8B;&#x4EF6;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;&#x3002;&#x8FD4;&#x56DE;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x7ED3;&#x679C;&#x6839;&#x636E;&#x7528;&#x6237;&#x8BBE;&#x5B9A;&#x7684;&#x5B57;&#x7B26;&#x7F16;&#x7801; (charset) &#x518D;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x8282;&#x6570;&#x7EC4;&#x3002;</p>
<h2 id="patternlayoutencoder">PatternLayoutEncoder</h2>
<p>&#x7531;&#x4E8E; <code>PatternLayout</code> &#x662F;&#x6700;&#x5E38;&#x7528;&#x7684; layout&#xFF0C;logback &#x4F7F;&#x7528; <code>PatternLayoutEncoder</code> &#x6765;&#x6EE1;&#x8DB3;&#x8FD9;&#x79CD;&#x7528;&#x6CD5;&#x3002;&#x5B83;&#x6269;&#x5C55;&#x4E86; <code>LayoutWrappingEncoder</code>&#xFF0C;&#x88AB;&#x9650;&#x5236;&#x7528;&#x6765;&#x5305;&#x88F9; <code>PatternLayout</code> &#x5B9E;&#x4F8B;&#x3002;</p>
<p>&#x5728; logback 0.9.19 &#x7248;&#x672C;&#xFF0C;&#x65E0;&#x8BBA; <code>FileAppender</code> &#x8FD8;&#x662F;&#x5176;&#x5B50;&#x7C7B;&#x901A;&#x8FC7; <code>PatternLayout</code> &#x6765;&#x8FDB;&#x884C;&#x914D;&#x7F6E;&#xFF0C;&#x90FD;&#x5FC5;&#x987B;&#x4F7F;&#x7528; <code>PatternLayoutEncoder</code> &#x6765;&#x4EE3;&#x66FF;&#x3002;&#x5177;&#x4F53;&#x7684;&#x89E3;&#x91CA;&#x53C2;&#x89C1;&#xFF1A;<a href="https://logback.qos.ch/codes.html#layoutInsteadOfEncoder" target="_blank">layoutInsteadOfEncoder</a>&#x3002;</p>
<h4 id="immediateflush-&#x5C5E;&#x6027;">immediateFlush &#x5C5E;&#x6027;</h4>
<p>&#x5728; <code>LOGBACK 1.2.0</code> &#x4E2D;, <code>immediateFlush</code> &#x5C5E;&#x6027;&#x662F; appender &#x7684;&#x4E00;&#x90E8;&#x5206;&#x3002;</p>
<h4 id="&#x7528;&#x683C;&#x5F0F;&#x5316;&#x5B57;&#x7B26;&#x4E32;&#x4F5C;&#x4E3A;&#x5F00;&#x5934;">&#x7528;&#x683C;&#x5F0F;&#x5316;&#x5B57;&#x7B26;&#x4E32;&#x4F5C;&#x4E3A;&#x5F00;&#x5934;</h4>
<p>&#x4E3A;&#x4E86;&#x5E2E;&#x52A9;&#x89E3;&#x6790;&#x65E5;&#x5FD7;&#x6587;&#x4EF6;&#xFF0C;logback &#x53EF;&#x4EE5;&#x5C06;&#x683C;&#x5F0F;&#x5316;&#x5B57;&#x7B26;&#x4E32;&#x63D2;&#x5165;&#x5230;&#x65E5;&#x5FD7;&#x6587;&#x4EF6;&#x7684;&#x9876;&#x90E8;&#x3002;&#x8FD9;&#x4E2A;&#x529F;&#x80FD;&#x9ED8;&#x8BA4;&#x662F;<strong>&#x5173;&#x95ED;</strong>&#x7684;&#x3002;&#x53EF;&#x4EE5;&#x4E3A;&#x76F8;&#x5173;&#x7684; <code>PatternLayoutEncoder</code> &#x8BBE;&#x7F6E; <code>outputPatternAsHeader</code> &#x5C5E;&#x6027;&#x7684;&#x503C;&#x4E3A; <code>true</code> &#x6765;&#x5F00;&#x542F;&#x8FD9;&#x4E2A;&#x529F;&#x80FD;&#x3002;&#x4E0B;&#x9762;&#x662F;&#x793A;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-java">&lt;appender name=&quot;FILE&quot; class=&quot;ch.qos.logback.core.FileAppender&quot;&gt; 
  &lt;file&gt;foo.log&lt;/file&gt;
  &lt;encoder&gt;
    &lt;pattern&gt;%d %-5level [%thread] %logger{0}: %msg%n&lt;/pattern&gt;
    &lt;outputPatternAsHeader&gt;true&lt;/outputPatternAsHeader&gt;
  &lt;/encoder&gt; 
&lt;/appender&gt;
</code></pre>
<p>&#x5C06;&#x4F1A;&#x5728;&#x65E5;&#x5FD7;&#x6587;&#x4EF6;&#x4E2D;&#x8F93;&#x51FA;&#x7C7B;&#x4F3C;&#x4E0B;&#x9762;&#x7684;&#x65E5;&#x5FD7;&#xFF1A;</p>
<pre><code class="lang-java">#logback.classic pattern: %d [%thread] %-5level %logger{36} - %msg%n
2012-04-26 14:54:38,461 [main] DEBUG com.foo.App - Hello world
2012-04-26 14:54:38,461 [main] DEBUG com.foo.App - Hi again
...
</code></pre>
<p>&#x4EE5; &quot;#logback.classic pattern&quot; &#x5F00;&#x5934;&#x7684;&#x884C;&#x5C31;&#x662F;&#x65B0;&#x63D2;&#x5165;&#x7684;&#x884C;&#x3002;</p>



                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="04第四章Appenders.html" class="navigation navigation-prev " aria-label="Previous page: 第四章：Appenders">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="06第六章Layouts.html" class="navigation navigation-next " aria-label="Next page: 第六章：Layouts">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"第五章：Encoder","level":"1.6","depth":1,"next":{"title":"第六章：Layouts","level":"1.7","depth":1,"path":"06第六章Layouts.md","ref":"06第六章Layouts.md","articles":[]},"previous":{"title":"第四章：Appenders","level":"1.5","depth":1,"path":"04第四章Appenders.md","ref":"04第四章Appenders.md","articles":[]},"dir":"ltr"},"config":{"plugins":["add-js-css","myseo"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"add-js-css":{"js":["./lib/site.js"]},"myseo":{"description":"logback中文网包含了logback中文文档，最新资讯，应用案例等。logback 继承自 log4j，它建立在有十年工业经验的日志系统之上。它比其它所有的日志系统更快并且更小，包含了许多独特并且有用的特性。","keywords":"logback中文文档, logback api文档, logback log4j,springboot logback,logback日志类型","titlePrefix":"logback中文网|"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","keywords":"","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"logback中文手册","gitbook":"*","description":""},"file":{"path":"05第五章Encoder.md","mtime":"2019-02-12T05:09:20.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-02-24T03:19:05.191Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-add-js-css/fda70cfc36440304bb976a11f47eb151-site.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

